package com.lrkj.system.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.system.domain.PrintTemplet;
import com.lrkj.system.service.IPrintTempletService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 打印模板Controller
 *
 * @author yajun_ren
 * @date 2022-04-07
 */
@RestController
@RequestMapping("/system/printTemplet")
@Api(tags = "打印模板")
public class PrintTempletController extends BaseController
{
    @Autowired
    private IPrintTempletService printTempletService;

    /**
     * 查询打印模板列表
     */
    @ApiOperation(value = "查询打印模板列表", notes = "查询打印模板列表")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:list')")
    @GetMapping("/list")
    public TableDataInfo list(PrintTemplet printTemplet)
    {
        startPage();
        this.changeParameter(printTemplet.getParams());
        List<PrintTemplet> list = printTempletService.selectPrintTempletList(printTemplet);
        return getDataTable(list);
    }

    /**
     * 导出打印模板列表
     */
	@ApiOperation(value = "导出打印模板列表", notes = "导出打印模板列表")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:export')")
    @Log(title = "打印模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PrintTemplet printTemplet)
    {
        List<PrintTemplet> list = printTempletService.selectPrintTempletList(printTemplet);
        ExcelUtil<PrintTemplet> util = new ExcelUtil<PrintTemplet>(PrintTemplet.class);
        return util.exportExcel(list, "打印模板数据");
    }

    /**
     * 获取打印模板详细信息
     */
	@ApiOperation(value = "获取打印模板详细信息", notes = "获取打印模板详细信息")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(printTempletService.selectPrintTempletById(id));
    }

    /**
     * 新增打印模板
     */
    @ApiOperation(value = "新增打印模板", notes = "新增打印模板")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:add')")
    @Log(title = "打印模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PrintTemplet printTemplet)
    {
        return toAjax(printTempletService.insertPrintTemplet(printTemplet));
    }

    /**
     * 修改打印模板
     */
    @ApiOperation(value = "修改打印模板", notes = "修改打印模板")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:edit')")
    @Log(title = "打印模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PrintTemplet printTemplet)
    {
        return toAjax(printTempletService.updatePrintTemplet(printTemplet));
    }

    /**
     * 删除打印模板
     */
    @ApiOperation(value = "删除打印模板", notes = "删除打印模板")
    @PreAuthorize("@ss.hasPermi('system:printTemplet:remove')")
    @Log(title = "打印模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(printTempletService.deletePrintTempletByIds(ids));
    }
}
